// pages/workbench/index.js
import { request } from '../../api/request.js'
Page({
  data: {
    swiperList: [],
    list: [],
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getList()
  },
  // 判断token
  getList() {
    const token = wx.getStorageSync("token")
    if (token === "") {
      wx.redirectTo({
        url: "../login/index",
      })
    } else {
      request({
        url: "/index",
        method: "POST",
      }).then(res => {
        console.log(res)
        this.setData({
          swiperList: res.data.bannerLists,
          list: res.data,
        })
      })
    }
  },
  earnings() {
    wx.showLoading({
      title: '加载中',
      success: (res => {
        if (res.errMsg === "showLoading:ok") {
          wx.navigateTo({
            url: "./compents/earnings/index",
            success: (res => {
              if (res.errMsg === "navigateTo:ok") {
                wx.hideLoading()
              }
            })
          })
        }
      })
    })

  },
  guide() {
    console.log('指南')
    wx.showLoading({
      title: '加载中',
      success: (res => {
        if (res.errMsg === "showLoading:ok") {
          wx.navigateTo({
            url: "./compents/operation/index",
            success: (res => {
              if (res.errMsg === "navigateTo:ok") {
                wx.hideLoading()
              }
            })
          })
        }
      })
    })

  }

})
